
//基础类型(数字、布尔、字符串、undefined、NaN)
var n:number = 123
console.log(n)

var bool:boolean = true

bool = false

//any任意类型
var a:any = 123

//函数中的类型约束
function sum(b:number,c:number):number{
	let m = b + c
	return m
}
//函数不返回任何内容
function other(b:number):void{
	console.log(b)
}
//可选参数
function havefood(food:string,fruit:string='老八蜜汁小汉堡'){
	console.log(`午饭吃${food},水果吃${fruit}`)
}
havefood('浇给')

//rest剩余参数
function sum1(b:number,c:number,...arg:number[]):number{
	let m = b + c
	arg.forEach((i:number)=>{
		m += i
	})
	return m
}
console.log(sum1(1,2,3,4,5,6,7,8,9))

//TS中有两种箭头(比较少用)
//1.代表类型约束的箭头
//2.箭头函数的箭头

let add:(b:number,c:number) => number // 返回值类型箭头
add = (num1,num2) => {
	return num1 + num2
}